package com.lwj.liwanjia.utils;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.lwj.liwanjia.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/9/13.
 */

public class ZfFangshiDialog extends Dialog implements View.OnClickListener {

    private Context context;
    private ImageView cbZaixian;
    private ImageView cbHuodaofukuan;
    private int section = 0;//选中
    private RelativeLayout rlQueren;

    public ZfFangshiDialog(Context context) {
        super(context, R.style.MyDialog);
        this.context = context;

    }

    public int getSection() {
        return section;
    }

    public RelativeLayout getQueRen() {
        return rlQueren;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pay_fangshi_layout);
        initView();
    }

    private void initView() {
        Window window = getWindow();
        window.setGravity(Gravity.BOTTOM);
        window.setWindowAnimations(R.style.dialog_animation);
        WindowManager.LayoutParams params = window.getAttributes();
        WindowManager manager = ((Activity) context).getWindowManager();
        setCanceledOnTouchOutside(false);
        params.width = params.MATCH_PARENT;
        params.height = params.WRAP_CONTENT;
        window.setAttributes(params);
        RelativeLayout rlZaixian = (RelativeLayout) findViewById(R.id.rl_zaixian);
        rlZaixian.setOnClickListener(this);
        RelativeLayout rlHuodao = (RelativeLayout) findViewById(R.id.rl_huodaofukuan);
        rlHuodao.setOnClickListener(this);
        rlQueren = (RelativeLayout) findViewById(R.id.queren);
        cbZaixian = (ImageView) findViewById(R.id.cb_zaixian);
        cbHuodaofukuan = (ImageView) findViewById(R.id.cb_huodaofukuan);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.rl_zaixian:
                cbZaixian.setImageResource(R.mipmap.gouxuan);
                cbHuodaofukuan.setImageResource(R.mipmap.weigouxuan);
                section = 0;
                break;
            case R.id.rl_huodaofukuan:
                cbZaixian.setImageResource(R.mipmap.weigouxuan);
                cbHuodaofukuan.setImageResource(R.mipmap.gouxuan);
                section = 1;
                break;
        }
    }

}
